package cn.gdchent.nativehotfix.andfix.manager

import android.content.Context
import cn.gdchent.nativehotfix.utils.AppVersionUtils
import com.alipay.euler.andfix.patch.PatchManager

/**
 * 管理所有的ＡndFix的api
 */
class AndFixPatchManager {

    companion object{
        private var mInstance: AndFixPatchManager?=null
        private var patchManager:PatchManager?=null
        fun getInstance(): AndFixPatchManager? {
            if(mInstance ==null){
                synchronized(AndFixPatchManager.javaClass,{
                    if(mInstance ==null){
                        mInstance = AndFixPatchManager()
                    }
                })
            }
            return mInstance
        }
    }

    //初始化AndFix
    fun initPatch(context: Context){
        patchManager = PatchManager(context)
        patchManager?.init(AppVersionUtils.getVersionName(context))
        patchManager?.loadPatch()
    }

    //添加patch
    fun addPatch(path:String){
        patchManager?.addPatch(path)
    }

}